<?php
/* 
 * Copyright (c) 2018-2021   All rights reserved.
 * 
 * 创建时间：2021-05-21 13:36
 *
 * 项目：upload  -  $  - editorWidget.php
 *
 * 作者：liwei 
 */

namespace lev\widgets\editors;

use Lev;
use lev\base\Widgetv;
use lev\helpers\EditorsHelper;
use lev\helpers\ModulesHelper;
use modules\editors\modules\ckeditor4\widgets\ckeditor4Widget;

!defined('INLEV') && exit('Access Denied LEV');


class editorWidget extends Widgetv
{

    public static function run($show = true)
    {
        parent::run($show); // TODO: Change the autogenerated stub
    }

    public static function wangEditor($inputname, $inputvalue, $input = [], $editorHeight = 300, $show = true) {
        $uploadUrl = Lev::toCurrent(['r'=>'upload/image', 'input'=>'editor', '_csrf'=>Lev::$app['_csrf'], 'iden'=>Lev::$app['iden'], 'identifier'=>APPVIDEN, 'id'=>APPVIDEN, 'inajax'=>1]);
        if (ModulesHelper::isInstallModule('editors')) {
            $ed = EditorsHelper::defaultEditor();
            if ($ed === 1 && ModulesHelper::isInstallModule('ckeditor4')) {
                return ckeditor4Widget::jsConfigAuto($input, $inputname, $inputvalue, $editorHeight, '', '', $show);
            }
        }
        return parent::render($show, __DIR__ . '/views/wangeditor.php', [
            'inputname' => $inputname,
            'inputvalue' => $inputvalue,
            'input' => $input,
            'editorHeight' => $editorHeight,
            'uploadUrl' => $uploadUrl,
        ]);
    }
}